
package at.fhj.ase.crypto.common.util;

import java.util.Collection;

/**
 * Class providing convenience and util methods.<br>
 * They can also be used with older JDK versions, therefore no Generics are used on purpose.
 * 
 * @author sfe | www.fh-joanneum.at | Practical Aspects of Cryptography
 */
public final class CollectionUtil {
  @SuppressWarnings("unchecked")
  public static Collection checkEmptyOrNull(final Collection c) {
    if (isNullOrEmpty(c)) {
      throw new IllegalArgumentException("Provided collection must not be empty or null");
    }
    return c;
  }

  @SuppressWarnings("unchecked")
  public static boolean isNullOrEmpty(final Collection c) {
    return CommonUtil.isNull(c) || c.isEmpty();
  }

  private CollectionUtil() {
    throw new AssertionError("CollectionUtil: Util classes are not intended/allowed to be instantiated!");
  }
}
